<?php
if($this->do=='plugin'){
	$this->check_access('global_plugin');
	$array=array();
	if($handle=opendir("core/plugins/")){
		while(false!==($dir=readdir($handle))){
			if ($dir!="."&&$dir!=".."&&is_dir(ROOT.'/core/plugins/'.$dir)){
				$info=@include(ROOT.'/core/plugins/'.$dir.'/info.php');
				if(!empty($info)){
					$info['install']=file_exists(ROOT.'/core/plugins/'.$dir.'/install.lock');
					$info['dir']=$dir;
					$array[]=$info;
				}
			}
		}
		closedir($handle);
	}

	$this->template->in("plugin_list",$array);
	$this->template->out('global.plugin.php');
}
if($this->do=='plugin_install'){
	$this->check_access('global_plugin');
	$dir=empty($_GET['dir'])?'':trim($_GET['dir']);
	@rename(ROOT.'/core/plugins/'.$dir.'/install.php',ROOT.'/core/plugins/'.$dir.'/install.lock');
}
if($this->do=='plugin_uninstall'){
	$this->check_access('global_plugin');
	$dir=empty($_GET['dir'])?'':trim($_GET['dir']);
	@rename(ROOT.'/core/plugins/'.$dir.'/install.lock',ROOT.'/core/plugins/'.$dir.'/install.php');
}